package Thread;
/**线程的状态
 * */
public class demo13 {
    public static void main(String[] args) throws InterruptedException {
        Thread t = new Thread(()->{ // TERMINTED
            while(true) {   // RUNNABLE
                 // 这里什么都不做
                // sleep外是RUNNABLE
                // 另外：join也会进入到TIMED_WAITING
                try {
                    // sleep()内是：TIMED_WAITING
                    Thread.sleep(2000);
                } catch (InterruptedException e) {
                    throw new RuntimeException(e);
                }
            }
        });

        System.out.println(t.getState()); // NEW：new 了Thread对象，还没start
        t.start();
        Thread.sleep(1000);
        System.out.println(t.getState());   // TERMINTED:内核中的线程已经结束了，但是Thread对象还在
    }
}
